<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><#include "/common/elibs.html"></head><body><div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="${request.contextPath}/index">首页</a>
        <a href="#">文化管理</a>
        <a>
          <cite>列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
      <i class="layui-icon" style="line-height:30px">ဂ</i></a>
  </div><div class="x-body">
    <div class="layui-row">
        <table class="layui-hide" id="test" lay-filter="test"></table>
        <!--<script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
          <button class="layui-btn layui-btn-sm" lay-event="add" id="add">
            <i class="layui-icon"></i>添加banner图</button>
        </div>
      </script>-->

      <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
      </script>
    </div></div><script>
    isToken();
      layui.use('table', function(){
          var table = layui.table;
          table.render({
              elem: '#test'
              ,url: path+'/pc/culture/getCultureList'
              ,toolbar: '#toolbarDemo'
              ,title: '用户数据表'
              ,headers:{'X-USER-TOKEN':localStorage.getItem("token")}
              ,cols: [[
                  {type: 'checkbox', fixed: 'left'}
                  ,{field:'bannerId',type:'numbers', title:'ID', width:80, fixed: 'left' }
              ,{field:'title', title:'标题', width:200 }
              ,{field:'content', title:'内容', width:200}
              ,{field:'type', title:'内容', width:200,
                      templet : function(res){
                          if (res.type == '1') {
                              return "班组文化";
                          } else if (res.type == '2') {
                              return "企业文化";
                          }
                      }}
              ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
          ]]
              ,request: {
                  pageName: 'currentPage' //页码的参数名称，默认：page
              }
              , parseData: function (res) { //res 即为原始返回的数据
                  return {
                      "code": res.code, //解析接口状态
                      "msg": res.message, //解析提示文本
                      "count": res.data.totalResult, //解析数据长度
                      "data": res.data.data //解析数据列表
                  }
              }
              ,page: true
              ,limit:10
              ,id: 'testReload'
      });
          var $ = layui.$, active = {reload: function(){
                  var tcaParentsId = $("#tcaParentsId").val();
                  var tcaName =  $("#tcaName").val();
                  if(tcaParentsId == "" && tcaName == ""){
                      return;
                  }
                  table.reload('testReload',{
                      where: { //设定异步数据接口的额外参数，任意设
                          tcaParentsId: tcaParentsId
                          ,tcaName: tcaName
                      }
                      ,page: {
                          curr: 1 //重新从第 1 页开始
                      }
                  }); //重载表格
           }}
          $('#sreach').on('click', function(){
              var type = $(this).data('type');
              active[type] ? active[type].call(this) : '';
          });//监听行工具事件
          table.on('tool(test)', function(obj){
              var data = obj.data;
              //console.log(obj)
              if(obj.event === 'edit'){
                  window.location.href = '${request.contextPath}/modules/culture/edit.html/?id='+obj.data.idCulture;
              }
          });
      });
    </script></body></html>